package com.swg.seckill.controller;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.swg.seckill.service.IUserService;
import com.swg.seckill.utils.ValidatorUtil;
import com.swg.seckill.utils.vo.LoginVo;
import com.swg.seckill.utils.vo.RespBean;
import com.swg.seckill.utils.vo.RespBeanEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @author swg
 */
@RestController
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    private IUserService iUserService;

    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }

    @PostMapping ("/doLogin")
    public RespBean doLogin(@RequestBody @Valid LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){

        return iUserService.login(loginVo,request,response);

    }
}
